package com.taxshare.purchaser.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.purchaser.entity.ElectronicledgerEntity;
import com.taxshare.purchaser.service.ElectronicLedgerService;
import com.taxshare.purchaser.view.dto.*;
import com.taxshare.purchaser.view.vo.InvoiceResultSummaryVO;
import com.taxshare.response.beans.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: ElectronicLedgerController
 * @Description: 电子抵账库
 * @author: luozhongyi
 * @date: 2021/3/25 14:50
 */
@RestController
@RequestMapping(value = "/electronicLedger")
@Api(tags = "电子底账库")
public class ElectronicLedgerController {

    @Autowired
    ElectronicLedgerService electronicLedgerService;

    @PostMapping("/list")
    @ApiOperation(value = "查询", notes = "查询")
    public Response<IPage<ElectronicledgerEntity>> list(@RequestBody PageRequest<ElectronicLedgerDTO> query) {
        return electronicLedgerService.list(query);
    }

    @ApiOperation(notes = "认证结果", value = "认证结果导出")
    @GetMapping("/export")
    public void exportResultExcel(HttpServletRequest request, HttpServletResponse httpServletResponse) throws Exception {
         electronicLedgerService.exportResultExcel(request,httpServletResponse);
    }

    @PostMapping("/init")
    @ApiOperation(value = "页面触发电子底账增量同步初始化", notes = "电子抵账库")
    public Response electronicLedgerInit(@RequestBody InvoiceSyncDTO bean) {
        return electronicLedgerService.electronicLedgerInit(bean);
    }

    @PostMapping("/sync")
    @ApiOperation(value = "页面触发电子底账同步", notes = "电子抵账库")
    public Response electronicLedgerSyn(@RequestBody InvoiceSyncDTO bean) {
        return electronicLedgerService.electronicLedgerSyn(bean);
    }

    @PostMapping("/refreshPeriod")
    @ApiOperation(value = "刷新税款所属期", notes = "刷新税款所属期")
    public Response refreshPeriod(String taxNo) {
        return electronicLedgerService.refreshPeriod(taxNo);
    }

    @PostMapping("/getTaxNoPeriod")
    @ApiOperation(value = "获取纳税人当前属期", notes = "获取纳税人当前属期")
    public Response getTaxNoPeriod(String taxNo) {
        return electronicLedgerService.getTaxNoPeriod(taxNo);
    }

    @PostMapping("/querySummary")
    @ApiOperation(value = "申请统计汇总表查询", notes = "统计分析")
    public Response querySummary(@RequestBody InvoiceSummaryDTO query) {
        return electronicLedgerService.querySummary(query);
    }

    @PostMapping("/queryResultSummary")
    @ApiOperation(value = "申请统计结果汇总表查询", notes = "统计分析")
    public Response<List<InvoiceResultSummaryVO>> queryResultSummary(@RequestBody PageRequest<InvoiceSummaryDTO> query) {
        return electronicLedgerService.queryResultSummary(query);
    }
}
